package no.ffi.gismoidm.pubsub;

import java.net.ServerSocket;
import java.net.Socket;
import no.ffi.gismoidm.idp.Config;

/**
 * This class listens for incoming connections. When a connection is made, 
 * @author anders
 */
public class ConnectionListener implements Runnable {
    int port = 1566; // TODO take from config file
    public ConnectionListener() { new Thread(this).start();}
    
    public void run() {
        int port = Integer.parseInt(Config.getProperty("MESSAGEROUTER_TCP_PORT","1566"));
        try {
            ServerSocket ss = new ServerSocket(port);
            while (true) {
                Socket s = ss.accept();
                // Pass the socket to the Neighbor constructor
                new Authenticator(s);
            }
        } catch (Exception e) { e.printStackTrace(); }
    }
}
